Skip to content

fix: Multi turn evaluation causes JSON serialization error#62

Merged
ViaDézo1er / cedric (viadezo1er) merged 8 commits intomainfrom
cedric/json-serialization-error-multi-turn-evaluation
Mar 12, 2026
Merged

fix: Multi turn evaluation causes JSON serialization error#62
ViaDézo1er / cedric (viadezo1er) merged 8 commits intomainfrom
cedric/json-serialization-error-multi-turn-evaluation

Conversation

@viadezo1er
Copy link
Contributor

Fix #38

Deserialize JSON using Braintrust custom deserialization function (bt_dumps from bt_json), allowing to deserialize the ChatCompletionMessage objects.

@viadezo1er ViaDézo1er / cedric (viadezo1er) force-pushed the cedric/json-serialization-error-multi-turn-evaluation branch from c6dca9e to de0f896 Compare March 9, 2026 23:40

resp = proxy_conn().post("function/invoke", json=request, headers=headers, stream=stream)
request = bt_dumps(request)
resp = proxy_conn().post("function/invoke", data=request, headers=headers, stream=stream)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so it's important to note that switching from json=request to data=request will mean we no longer set Content-Type: application/json when sending the request. I'd double check if this is okay. If it is, feel free to merge!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh yeah, let's also add a regression test for this - I'm actually going to block until we add that.

Co-authored-by: Abhijeet Prasad <[email protected]>
Currently tests OopenAI, Anthropic, Google
@viadezo1er ViaDézo1er / cedric (viadezo1er) force-pushed the cedric/json-serialization-error-multi-turn-evaluation branch from c104e90 to 9c510c5 Compare March 11, 2026 01:21
@viadezo1er
Copy link
Contributor Author

Oh yeah, let's also add a regression test for this - I'm actually going to block until we add that.

Test added, please review it

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test you added doesn't actually test invoke. Let's mock proxy_conn and test calling invoke directly.

)
)
except ImportError:
print("Anthropic not imported")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer if we wrote a test for each provider, and use https://docs.pytest.org/en/7.1.x/reference/reference.html#pytest-importorskip.

openai.Client().responses.with_raw_response now has tracing
Test added, very similar to the tests for the non raw responses
Deals with the create and parse methods
@viadezo1er
Copy link
Contributor Author

woooops

@viadezo1er
Copy link
Contributor Author

wrong branch

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

great!

@viadezo1er ViaDézo1er / cedric (viadezo1er) merged commit 962e499 into main Mar 12, 2026
33 checks passed
@viadezo1er ViaDézo1er / cedric (viadezo1er) deleted the cedric/json-serialization-error-multi-turn-evaluation branch March 12, 2026 16:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

JSON serialization error with Gemini 2.5 models in multi-turn evaluation

2 participants